using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace Sinacor.Infra.UI.Controls.SmartClient
{
    /// <summary>
    /// Controle responsavel por mostrar o LockPanel das telas
    /// </summary>
    public class SinacorLockPanel : Control
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SinacorLockPanel"/> class.
        /// </summary>
        public SinacorLockPanel()
        {
            this.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(SinacorLockPanel_PreviewKeyEvent);
            this.PreviewKeyUp += new System.Windows.Input.KeyEventHandler(SinacorLockPanel_PreviewKeyEvent);
            this.PreviewMouseDown += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseUp += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseRightButtonDown += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
            this.PreviewMouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(SinacorLockPanel_PreviewMouseEvents);
        }

        /// <summary>
        /// Handles the PreviewMouse events of the SinacorLockPanel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
        void SinacorLockPanel_PreviewMouseEvents(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            e.Handled = true;
        }

        /// <summary>
        /// Handles the PreviewKey events of the SinacorLockPanel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.KeyEventArgs"/> instance containing the event data.</param>
        void SinacorLockPanel_PreviewKeyEvent(object sender, System.Windows.Input.KeyEventArgs e)
        {
            e.Handled = true;
        }

        /// <summary>
        /// Sets the opacity.
        /// </summary>
        /// <param name="opacity">The opacity.</param>
        public void SetOpacity(double opacity)
        {
            this.Opacity = opacity;
        }

        /// <summary>
        /// responsavel por exibir o LockPanel
        /// </summary>
        public virtual void Show()
        {
            this.Visibility = Visibility.Visible;
            BringIntoView();
            this.Focus();            
        }

        /// <summary>
        /// responsavel por ocultar o LockPanel
        /// </summary>
        public void Hide()
        {
            this.Visibility = Visibility.Collapsed;
        }
    }

}
